<?php
namespace app\agent\controller;

use app\common\controller\AgentAction;

class Order extends AgentAction
{
	protected $modelClass = '\app\common\model\Orders';

	public function initialize()
    {
        parent::initialize();
    }

	public function index($status=''){
		$where[] = ['uid','=',UID];
		if ($status!=='') {
			$where[] = ['status','in',$status];
		}
        if (input('get.search')){
            $where[] = ['name', 'like', '%'.input('get.search').'%'];
        }
        if (input('get._sort')){
            $order = explode(',', input('get._sort'));
            $order = $order[0].' '.$order[1];
        }else{
            $order = 'id desc';
        }
        $dataList = $this->cModel->where($where)->order($order)->paginate('', false, page_param());
        return $dataList;
	}

	public function all(){
		$dataList = $this->index();
		$this->assign("dataList",$dataList);
		return $this->fetch("index");
	}

	public function wait(){
		$dataList = $this->index(1);
		$this->assign("dataList",$dataList);
		return $this->fetch("index");
	}

	public function appointment(){
		$dataList = $this->index(2);
		$this->assign("dataList",$dataList);
		return $this->fetch("index");
	}

	public function close(){
		$dataList = $this->index(0);
		$this->assign("dataList",$dataList);
		return $this->fetch("index");
	}

	public function detail($ordersn){
		$where[] = ['uid','=',UID];
		$where[] = ['ordersn','=',$ordersn];
		$data = $this->cModel->where($where)->find();
		$this->assign("data",$data);
		return $this->fetch();
	}

	public function photo(){
		$dataList = $this->index(3);
		$this->assign("dataList",$dataList);
		return $this->fetch("index");
	}

	public function psing(){
		$dataList = $this->index('4,5,6');
		$this->assign("dataList",$dataList);
		return $this->fetch("index");
	}
	
}